<!DOCTYPE HTML>
<html lang="en" >
    
    <head>
        
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <title>数据结构与算法（Python） | 数据结构与算法（Python）</title>
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <meta name="description" content="我们举一个可能不太恰当的例子：">
        <meta name="generator" content="GitBook 2.6.7">
        
        
        <meta name="HandheldFriendly" content="true"/>
        <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png">
        <link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon">
        
    <link rel="stylesheet" href="gitbook/style.css">
    
        
        <link rel="stylesheet" href="gitbook/plugins/gitbook-plugin-highlight/website.css">
        
    
        
        <link rel="stylesheet" href="gitbook/plugins/gitbook-plugin-search/search.css">
        
    
        
        <link rel="stylesheet" href="gitbook/plugins/gitbook-plugin-fontsettings/website.css">
        
    
    

        
    
    
    <link rel="next" href="./chapter1/index.html" />
    
    

        
    </head>
    <body>
        
        
    <div class="book"
        data-level="0"
        data-chapter-title="数据结构与算法（Python）"
        data-filepath="README.md"
        data-basepath="."
        data-revision="Fri Mar 31 2017 18:24:30 GMT+0800 (CST)"
        data-innerlanguage="">
    

<div class="book-summary">
    <nav role="navigation">
        <ul class="summary">
            
            
            
            

            

            
    
        <li class="chapter active" data-level="0" data-path="index.html">
            
                
                    <a href="./index.html">
                
                        <i class="fa fa-check"></i>
                        
                        数据结构与算法（Python）
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1" data-path="chapter1/index.html">
            
                
                    <a href="./chapter1/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.</b>
                        
                        引入概念
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.1" data-path="chapter1/section1.html">
            
                
                    <a href="./chapter1/section1.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.1.</b>
                        
                        第一次尝试
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="chapter1/section2.html">
            
                
                    <a href="./chapter1/section2.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.2.</b>
                        
                        算法的提出
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="chapter1/section3.html">
            
                
                    <a href="./chapter1/section3.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.3.</b>
                        
                        第二次尝试
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="chapter1/section4.html">
            
                
                    <a href="./chapter1/section4.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.4.</b>
                        
                        算法效率衡量
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="chapter1/section5.html">
            
                
                    <a href="./chapter1/section5.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.5.</b>
                        
                        算法分析
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="chapter1/section6.html">
            
                
                    <a href="./chapter1/section6.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.6.</b>
                        
                        常见时间复杂度
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="chapter1/section7.html">
            
                
                    <a href="./chapter1/section7.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.7.</b>
                        
                        Python内置类型性能分析
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="chapter1/section8.html">
            
                
                    <a href="./chapter1/section8.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.8.</b>
                        
                        数据结构
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2" data-path="chapter2/index.html">
            
                
                    <a href="./chapter2/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.</b>
                        
                        顺序表
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.1" data-path="chapter2/section1.html">
            
                
                    <a href="./chapter2/section1.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.1.</b>
                        
                        顺序表的形式
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.2" data-path="chapter2/section2.html">
            
                
                    <a href="./chapter2/section2.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.2.</b>
                        
                        顺序表的结构与实现
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.3" data-path="chapter2/section3.html">
            
                
                    <a href="./chapter2/section3.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.3.</b>
                        
                        顺序表的操作
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.4" data-path="chapter2/section4.html">
            
                
                    <a href="./chapter2/section4.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.4.</b>
                        
                        Python中的顺序表
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3" data-path="chapter3/index.html">
            
                
                    <a href="./chapter3/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.</b>
                        
                        链表
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.1" data-path="chapter3/section1.html">
            
                
                    <a href="./chapter3/section1.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.1.</b>
                        
                        单向链表
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.2" data-path="chapter3/section2.html">
            
                
                    <a href="./chapter3/section2.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.2.</b>
                        
                        单项循环链表
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.3" data-path="chapter3/section3.html">
            
                
                    <a href="./chapter3/section3.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.3.</b>
                        
                        双向链表
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="4" data-path="chapter4/index.html">
            
                
                    <a href="./chapter4/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.</b>
                        
                        栈
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.1" data-path="chapter4/section1.html">
            
                
                    <a href="./chapter4/section1.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.1.</b>
                        
                        栈结构实现
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="5" data-path="chapter5/index.html">
            
                
                    <a href="./chapter5/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.</b>
                        
                        队列
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="5.1" data-path="chapter5/section1.html">
            
                
                    <a href="./chapter5/section1.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.1.</b>
                        
                        队列的实现
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.2" data-path="chapter5/section3.html">
            
                
                    <a href="./chapter5/section3.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.2.</b>
                        
                        双端队列
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="6" data-path="chapter6/index.html">
            
                
                    <a href="./chapter6/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.</b>
                        
                        排序与搜索
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="6.1" data-path="chapter6/section1.html">
            
                
                    <a href="./chapter6/section1.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.1.</b>
                        
                        冒泡排序
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.2" data-path="chapter6/section2.html">
            
                
                    <a href="./chapter6/section2.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.2.</b>
                        
                        选择排序
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.3" data-path="chapter6/section3.html">
            
                
                    <a href="./chapter6/section3.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.3.</b>
                        
                        插入排序
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.4" data-path="chapter6/section4.html">
            
                
                    <a href="./chapter6/section4.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.4.</b>
                        
                        快速排序
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.5" data-path="chapter6/section5.html">
            
                
                    <a href="./chapter6/section5.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.5.</b>
                        
                        希尔排序
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.6" data-path="chapter6/section6.html">
            
                
                    <a href="./chapter6/section6.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.6.</b>
                        
                        归并排序
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.7" data-path="chapter6/section7.html">
            
                
                    <a href="./chapter6/section7.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.7.</b>
                        
                        常见排序算法效率比较
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.8" data-path="chapter6/section8.html">
            
                
                    <a href="./chapter6/section8.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.8.</b>
                        
                        搜索
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="7" data-path="chapter7/index.html">
            
                
                    <a href="./chapter7/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.</b>
                        
                        树与树算法
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="7.1" data-path="chapter7/section1.html">
            
                
                    <a href="./chapter7/section1.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.1.</b>
                        
                        二叉树
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.2" data-path="chapter7/section2.html">
            
                
                    <a href="./chapter7/section2.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.2.</b>
                        
                        二叉树的遍历
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    


            
            <li class="divider"></li>
            <li>
                <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
                    Published with GitBook
                </a>
            </li>
            
        </ul>
    </nav>
</div>

    <div class="book-body">
        <div class="body-inner">
            <div class="book-header" role="navigation">
    <!-- Actions Left -->
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="./" >数据结构与算法（Python）</a>
    </h1>
</div>

            <div class="page-wrapper" tabindex="-1" role="main">
                <div class="page-inner">
                
                
                    <section class="normal" id="section-">
                    
                        <h1 id="&#x6570;&#x636E;&#x7ED3;&#x6784;&#x4E0E;&#x7B97;&#x6CD5;&#xFF08;python&#xFF09;">&#x6570;&#x636E;&#x7ED3;&#x6784;&#x4E0E;&#x7B97;&#x6CD5;&#xFF08;Python&#xFF09;</h1>
<h2 id="why&#xFF1F;">Why&#xFF1F;</h2>
<p>&#x6211;&#x4EEC;&#x4E3E;&#x4E00;&#x4E2A;&#x53EF;&#x80FD;&#x4E0D;&#x592A;&#x6070;&#x5F53;&#x7684;&#x4F8B;&#x5B50;&#xFF1A;</p>
<p>&#x5982;&#x679C;&#x5C06;&#x6700;&#x7EC8;&#x5199;&#x597D;&#x8FD0;&#x884C;&#x7684;&#x7A0B;&#x5E8F;&#x6BD4;&#x4F5C;&#x6218;&#x573A;&#xFF0C;&#x6211;&#x4EEC;&#x7801;&#x519C;&#x4FBF;&#x662F;&#x6307;&#x6325;&#x4F5C;&#x6218;&#x7684;&#x5C06;&#x519B;&#xFF0C;&#x800C;&#x6211;&#x4EEC;&#x6240;&#x5199;&#x7684;&#x4EE3;&#x7801;&#x4FBF;&#x662F;&#x58EB;&#x5175;&#x548C;&#x6B66;&#x5668;&#x3002;</p>
<p><strong>&#x90A3;&#x4E48;&#x6570;&#x636E;&#x7ED3;&#x6784;&#x548C;&#x7B97;&#x6CD5;&#x662F;&#x4EC0;&#x4E48;&#xFF1F;&#x7B54;&#x66F0;&#xFF1A;&#x5175;&#x6CD5;&#xFF01;</strong></p>
<p>&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x4E0D;&#x770B;&#x5175;&#x6CD5;&#x5728;&#x6218;&#x573A;&#x4E0A;&#x8089;&#x640F;&#xFF0C;&#x5982;&#x6B64;&#xFF0C;&#x53EF;&#x80FD;&#x4F1A;&#x80DC;&#x5229;&#xFF0C;&#x53EF;&#x80FD;&#x4F1A;&#x5931;&#x8D25;&#x3002;&#x5373;&#x4F7F;&#x80DC;&#x5229;&#xFF0C;&#x53EF;&#x80FD;&#x4E5F;&#x4F1A;&#x4ED8;&#x51FA;&#x5DE8;&#x5927;&#x7684;&#x4EE3;&#x4EF7;&#x3002;&#x6211;&#x4EEC;&#x5199;&#x7A0B;&#x5E8F;&#x4EA6;&#x7136;&#xFF1A;&#x6CA1;&#x6709;&#x770B;&#x8FC7;&#x6570;&#x636E;&#x7ED3;&#x6784;&#x548C;&#x7B97;&#x6CD5;&#xFF0C;&#x6709;&#x65F6;&#x9762;&#x5BF9;&#x95EE;&#x9898;&#x53EF;&#x80FD;&#x4F1A;&#x6CA1;&#x6709;&#x4EFB;&#x4F55;&#x601D;&#x8DEF;&#xFF0C;&#x4E0D;&#x77E5;&#x5982;&#x4F55;&#x4E0B;&#x624B;&#x53BB;&#x89E3;&#x51B3;&#xFF1B;&#x5927;&#x90E8;&#x5206;&#x65F6;&#x95F4;&#x53EF;&#x80FD;&#x89E3;&#x51B3;&#x4E86;&#x95EE;&#x9898;&#xFF0C;&#x53EF;&#x662F;&#x5BF9;&#x7A0B;&#x5E8F;&#x8FD0;&#x884C;&#x7684;&#x6548;&#x7387;&#x548C;&#x5F00;&#x9500;&#x6CA1;&#x6709;&#x610F;&#x8BC6;&#xFF0C;&#x6027;&#x80FD;&#x4F4E;&#x4E0B;&#xFF1B;&#x6709;&#x65F6;&#x4F1A;&#x501F;&#x52A9;&#x522B;&#x4EBA;&#x5F00;&#x53D1;&#x7684;&#x5229;&#x5668;&#x6682;&#x65F6;&#x89E3;&#x51B3;&#x4E86;&#x95EE;&#x9898;&#xFF0C;&#x53EF;&#x662F;&#x9047;&#x5230;&#x6027;&#x80FD;&#x74F6;&#x9888;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x53C8;&#x4E0D;&#x77E5;&#x8BE5;&#x5982;&#x4F55;&#x8FDB;&#x884C;&#x9488;&#x5BF9;&#x6027;&#x7684;&#x4F18;&#x5316;&#x3002;</p>
<p>&#x5982;&#x679C;&#x6211;&#x4EEC;&#x5E38;&#x770B;&#x5175;&#x6CD5;&#xFF0C;&#x4FBF;&#x53EF;&#x505A;&#x5230;&#x80F8;&#x6709;&#x6210;&#x7AF9;&#xFF0C;&#x6709;&#x65F6;&#x4F1A;&#x4E8B;&#x534A;&#x529F;&#x500D;&#xFF01;&#x540C;&#x6837;&#xFF0C;&#x5982;&#x679C;&#x6211;&#x4EEC;&#x5E38;&#x770B;&#x6570;&#x636E;&#x7ED3;&#x6784;&#x4E0E;&#x7B97;&#x6CD5;&#xFF0C;&#x6211;&#x4EEC;&#x5199;&#x7A0B;&#x5E8F;&#x65F6;&#x4E5F;&#x80FD;&#x6E38;&#x5203;&#x6709;&#x4F59;&#x3001;&#x660E;&#x5BDF;&#x79CB;&#x6BEB;&#xFF0C;&#x9047;&#x5230;&#x95EE;&#x9898;&#x65F6;&#x4EA6;&#x80FD;&#x5165;&#x6728;&#x4E09;&#x5206;&#x3001;&#x8FCE;&#x5203;&#x800C;&#x89E3;&#x3002;</p>
<p><strong>&#x6545;&#xFF0C;&#x6570;&#x636E;&#x7ED3;&#x6784;&#x548C;&#x7B97;&#x6CD5;&#x662F;&#x4E00;&#x540D;&#x7A0B;&#x5E8F;&#x5F00;&#x53D1;&#x4EBA;&#x5458;&#x7684;&#x5FC5;&#x5907;&#x57FA;&#x672C;&#x529F;&#xFF0C;&#x4E0D;&#x662F;&#x4E00;&#x671D;&#x4E00;&#x5915;&#x5C31;&#x80FD;&#x7EC3;&#x6210;&#x7EDD;&#x4E16;&#x9AD8;&#x624B;&#x7684;&#x3002;&#x51B0;&#x51BB;&#x4E09;&#x5C3A;&#x975E;&#x4E00;&#x65E5;&#x4E4B;&#x5BD2;&#xFF0C;&#x9700;&#x8981;&#x6211;&#x4EEC;&#x5E73;&#x65F6;&#x4E0D;&#x65AD;&#x7684;&#x4E3B;&#x52A8;&#x53BB;&#x5B66;&#x4E60;&#x79EF;&#x7D2F;&#x3002;</strong></p>
<p><strong>&#x901A;&#x8FC7;&#x4E09;&#x5929;&#x7684;&#x5B66;&#x4E60;&#xFF0C;&#x6211;&#x4EEC;&#x5E0C;&#x671B;&#x8BA9;&#x5927;&#x5BB6;&#x80FD;&#x7406;&#x89E3;&#x5176;&#x6982;&#x5FF5;&#xFF0C;&#x638C;&#x63E1;&#x5E38;&#x7528;&#x7684;&#x6570;&#x636E;&#x7ED3;&#x6784;&#x548C;&#x7B97;&#x6CD5;&#x3002;</strong></p>

                    
                    </section>
                
                
                </div>
            </div>
        </div>

        
        
        <a href="./chapter1/index.html" class="navigation navigation-next navigation-unique" aria-label="Next page: 引入概念"><i class="fa fa-angle-right"></i></a>
        
    </div>
</div>

        
<script src="gitbook/app.js"></script>

    
    <script src="gitbook/plugins/gitbook-plugin-search/lunr.min.js"></script>
    

    
    <script src="gitbook/plugins/gitbook-plugin-search/search.js"></script>
    

    
    <script src="gitbook/plugins/gitbook-plugin-sharing/buttons.js"></script>
    

    
    <script src="gitbook/plugins/gitbook-plugin-fontsettings/buttons.js"></script>
    

<script>
require(["gitbook"], function(gitbook) {
    var config = {"highlight":{},"search":{"maxIndexSize":1000000},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2}};
    gitbook.start(config);
});
</script>

        
    </body>
    
</html>
